#ifndef RS232_MOTOR_H
#define RS232_MOTOR_H

#include <fcntl.h>

typedef struct 
{
    int speed_front;
    int speed_rear;
    int IR;
    int IR2;
    int robot_voltage;
    int odometry;
    int robot_current;
    int robot_version;
} RS232Data;

class RS232Motor 
{

public:
    RS232Motor();
    
    int setRS232Motor33f_low_res(char speed1,char speed2);
    int setRS232Motor33f(short speed1,short speed2,unsigned char SpeedFlag);
    int setRS232MotorPID33f(char speed1,char speed2,char pp,char ii,char dd,short maxspeed);
    int stopMotorRS23233f();
    int getRS232Motor33f(RS232Data *dataL,RS232Data *dataR);
    
    int openRS232(const char *device, int baudrate);
    int readRS232(unsigned char *buffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead);
    int closeRS232();
    int writeRS232(unsigned char *buffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten);

    int hCOM;

private:
    short CRC16(unsigned char *adresse_tab , unsigned char taille_max);

};


#endif //RS232_MOTOR_H
